package com.softer.wxzj.controller;

import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.aop.annotation.LogRecord;
import com.softer.wxzj.common.aop.enums.LogOperationType;
import com.softer.wxzj.common.aop.enums.LogOperationUnit;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.entity.AccRateInfo;
import com.softer.wxzj.service.AccRateInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zcz
 * @date 2019/7/29
 */
@RestController
@RequestMapping("/accRateInfo")
public class AccRateInfoController {
    @Autowired
    private AccRateInfoService accRateInfoService;

    /**
     * 查询利率配置列表
     * @param page  分页实体
     * @param accRateInfo 查询条件
     * @return 列表
     */
    @RequestMapping("/getList")
    @LogRecord(description = "查询利率配置列表", operationUnit = LogOperationUnit.ACC_RATE_INFO, operationType = LogOperationType.SELECT)
    public PageInfo<AccRateInfo> getList(Page page, AccRateInfo accRateInfo) {
        return accRateInfoService.getList(page, accRateInfo);
    }

    /**
     * 新增利率配置
     * @param accRateInfo
     * @return
     */
    @PostMapping("/add")
    @LogRecord(description = "新增利率配置", operationUnit = LogOperationUnit.ACC_RATE_INFO, operationType = LogOperationType.INSERT)
    public CommonResult add(AccRateInfo accRateInfo) {
        return accRateInfoService.insert(accRateInfo);
    }

    /**
     * 删除利率配置
     * @param id
     * @return
     */
    @PostMapping("/delete")
    @LogRecord(description = "删除利率配置", operationUnit = LogOperationUnit.ACC_RATE_INFO, operationType = LogOperationType.DELETE)
    public CommonResult delete(@RequestParam("id") String id) {
        return accRateInfoService.delete(id);
    }
    /**
     * 修改利率配置
     * @param accRateInfo
     * @return
     */
    @PostMapping("/update")
    @LogRecord(description = "修改利率配置", operationUnit = LogOperationUnit.ACC_RATE_INFO, operationType = LogOperationType.UPDATE)
    public CommonResult update(AccRateInfo accRateInfo) {
        return accRateInfoService.update(accRateInfo);
    }

    /**
     * 查询利率配置详情
     * @param id
     * @return
     */
    @RequestMapping("/getInfo")
    @LogRecord(description = "查询利率配置详情", operationUnit = LogOperationUnit.ACC_RATE_INFO, operationType = LogOperationType.SELECT)
    public AccRateInfo getInfo(@RequestParam("id") String id) {
        return accRateInfoService.getInfo(id);
    }
}
